/**
 * 
 */
package ga.nqueens;

import java.util.LinkedList;
import java.util.List;

import org.jheuristics.ga.operators.probabilities.ConstantProbability;

import com.sun.org.apache.bcel.internal.generic.IINC;

import junit.framework.TestCase;

/**
 * @author thiago
 *
 */
public class GoodSwapMutationTest extends TestCase {

	/* (non-Javadoc)
	 * @see junit.framework.TestCase#setUp()
	 */
	protected void setUp() throws Exception {
		super.setUp();
	}

	/* (non-Javadoc)
	 * @see junit.framework.TestCase#tearDown()
	 */
	protected void tearDown() throws Exception {
		super.tearDown();
	}

	public final void testDoSwap() {
		
		GoodSwapMutation swap = new GoodSwapMutation(new ConstantProbability(1));
		
		List<Integer> gens = new LinkedList<Integer>();
		
		gens.add(0, 2);
		gens.add(1, 6);
		gens.add(2, 9);
		gens.add(3, 3);
		gens.add(4, 5);
		gens.add(5, 0);
		gens.add(6, 4);
		gens.add(7, 1);
		gens.add(8, 7);
		gens.add(9, 8);
		
		
		int hits [] = new Board(gens).hitsByQueen();
		
		assertEquals(8, swap.getMoreHitted(hits));
		assertEquals(0, swap.getLessHitted(hits));
		
		swap.doSwap(gens);
		
		
		assertEquals(new Integer(2), gens.get(8));
	}

}
